using System;
using System.Collections;
using System.Drawing;

namespace Jonathan.XhtmlRichTextBox
{
    /// <summary>
    /// Summary description for RtfColorTable.
    /// </summary>
    public class RtfColorTable
    {
        private int numberOfColors = 0;
        private string colortbl;
        private Hashtable loadedColors = new Hashtable();

        public RtfColorTable ()
        {
            //
            // TODO: Add constructor logic here
            //
            colortbl = "{\\colortbl;";
        }

        public int UseColor (Color key)
        {
            if (loadedColors.ContainsKey(key))
            {
                return (int)loadedColors[key];
            }
            else
            {
                colortbl += "\\red" + key.R + "\\green" + key.G + "\\blue" + key.B + ";";
                loadedColors.Add(key, ++numberOfColors);
                return numberOfColors;
            }
        }

        public override string ToString ()
        {
            return colortbl + "}";
        }
    }
}
